<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <script>
       // 自己定义 数组扩展方法  求和 和 最大值
      Array.prototype.max=function(){
       console.log(this)
       return Math.max(...this)
      }

      let arr=[1,5,4,9,3]
      console.log(arr.max());


      Array.prototype.sum=function(){
      //   let sum=0
      //  for(let i=0;i<this.length;i++){
      //   sum+=this[i]
      //  }
      const sum=this.reduce((prve,item)=> prve+item,0)
       return sum
      }
      let arr1=[1,6,7,19,2,3,4]
      console.log(arr1.sum());

      Array.prototype.min=function(){
        let min=this[0]
        for(let i=0;i<this.length;i++){
          min=min>this[i]?this[i]:min
        }
       return min
      }
  
      let arr2=[2,5,79,45,12,87]
      console.log(arr2.min());
    </script>
  </body>
</html>
